/**
 * Created by jijin on 2017/7/19.
 */
import React, { Component } from 'react';
import {
  View,
  Text,
  ListView
} from 'react-native';
import {AppColors} from '../../../style';
import MenuItem from './menu-item';

export default class MenuList extends Component {

  constructor(props) {
    super(props);
  }

  render() {
    let dataSource = new ListView.DataSource({
      rowHasChanged: (r1, r2) => r1 !== r2,
    });

    const _renderRow = (item) => {
      return (
        <MenuItem
          id={item.id}
          title={item.title}
          tintColor={AppColors.brand.black}
          icon={item.androidIcon}
          background={item.androidBackground}
          isSelected={this.props.selectedItem === item.id}
          onPress={(section) => this.props.onSectionChange(section)}
        />
      );
    };

    let {items} = this.props;
    return (
      <ListView
        dataSource={dataSource.cloneWithRows(items)}
        renderRow={_renderRow}
      />
    )
  }
}